package com.hl.web;

import com.github.pagehelper.PageInfo;
import com.hl.pojo.Consultanttraining;
import com.hl.pojo.Publicwelfarecenter;
import com.hl.service.PublicCenterService;
import com.hl.util.GeneralResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/public")
@CrossOrigin
public class PublicCenterController {
    @Autowired
    private PublicCenterService publicCenterService;
    @RequestMapping("/getPublicCenterMessage")
    public GeneralResult getPublicCenterMessage(Integer page,Integer pageSize){
        System.out.println("后端接收的数据是：" + page + pageSize);
        PageInfo<Publicwelfarecenter> pageInfo = publicCenterService.getPublicCenterMessage(page,pageSize);
        System.out.println(pageInfo);
        List<PageInfo> list = new ArrayList<>();
        list.add(pageInfo);
        System.out.println("后端返回的数据是：" + GeneralResult.success(list));
        return GeneralResult.success(list);
    }

    @RequestMapping("/shanChuPublicCenterMessage")
    public GeneralResult shanChuPublicCenterMessage(Integer id){
        GeneralResult res = publicCenterService.shanChuPublicCenterMessage(id);
        return res;
    }

    @RequestMapping("/xiuGaiPublicCenterMessage")
    public GeneralResult xiuGaiPublicCenterMessage(@RequestBody Publicwelfarecenter publicwelfarecenter){
        GeneralResult res = publicCenterService.xiuGaiPublicCenterMessage(publicwelfarecenter);
        return res;
    }

    @RequestMapping("/xinZengPublicCenterMessage")
    public GeneralResult xinZengPublicCenterMessage(@RequestBody Publicwelfarecenter publicwelfarecenter){
        GeneralResult res = publicCenterService.xinZengPublicCenterMessage(publicwelfarecenter);
        return res;
    }

    @RequestMapping("/souSuoPublicCenterMessage")
    public GeneralResult souSuoPublicCenterMessage(@RequestBody Publicwelfarecenter publicwelfarecenter){
        GeneralResult res = publicCenterService.souSuoPublicCenterMessage(publicwelfarecenter);
        return res;
    }
}
